<?php

//kiểm tra những khách hàng có tổng cọc bị lưu sai
include_once '../include/common.php';
$core = new core();

$list_customer_order = $core->db->get_results("SELECT * FROM zen_customer_order");
if($list_customer_order){
    foreach($list_customer_order as $order){
        $data_total_payment = $core->db->get_row("SELECT sum(payment) as total_payment FROM zen_payment WHERE customer_order_id=".$order->customer_order_id);
        if($data_total_payment->total_payment > 0){
            if($data_total_payment->total_payment != $order->total_payment){
                echo "customer_order_id=".$order->customer_order_id."<br/>";
            }else{
                echo "Du lieu dung<br/>";
            }
        }else{
            if($order->total_payment !=0){
                 echo "customer_order_id 02=".$order->customer_order_id."<br/>";
            }else{
                 echo "khong co coc<br/>";
            }
           
        }

        //sync data
        //        $data_total_payment = $core->db->get_row("SELECT sum(payment) as total_payment FROM zen_payment WHERE customer_order_id=".$order->customer_order_id);
//        if($data_total_payment->total_payment > 0){
//            $total_payment = $data_total_payment->total_payment;
//        }else{
//            $total_payment =0;
//        }
//        $total_current_money = $total_payment - $order->total_order_money ;
//        $core->db->query("UPDATE zen_customer_order SET total_payment=$total_payment,
//                        total_current_money= $total_current_money
//                            WHERE customer_order_id=$order->customer_order_id");
//       echo "query="."UPDATE zen_customer_order SET total_payment=$total_payment,
//                        total_current_money= $total_current_money
//                            WHERE customer_order_id=$order->customer_order_id";
//        echo "ok ".$count."<br/>";
//        $count++;
        
    }
    
}
echo "DONE";
?>